package engine;

import java.awt.Graphics2D;

import resources.manager.ResourceManager;

import com.golden.gamedev.GameEngine;
import com.golden.gamedev.GameObject;
import com.golden.gamedev.object.Background;
import com.golden.gamedev.object.Sprite;
import com.golden.gamedev.object.background.ImageBackground;

public class EndMenu extends GameObject {


	
	
	Background myBackground;
	Sprite myComplete;
	Sprite myClickMessage;
	private int myLevel;
	private int myMaxLevel;
	
	 
	public EndMenu(GameEngine parent, int level) {
		super(parent);
		ResourceManager manager=ResourceManager.getInstance();
		manager.addResourcesFromFile("menus");
		myBackground=new ImageBackground(getImage(manager.getString("background")));
		myComplete = new Sprite(getImage(manager.getString("complete")));
		myClickMessage = new Sprite(getImage(manager.getString("click")));
		myLevel = level + 1;	
		myMaxLevel=6;
	}

	@Override
	public void initResources() {
		
	}

	@Override
	public void render(Graphics2D g) {
		myBackground.render(g);
		myComplete.render(g);
		myClickMessage.render(g, 150, 300);
	}

	@Override
	public void update(long elapsedTime) {
		myBackground.update(elapsedTime);
		myComplete.update(elapsedTime);
		myClickMessage.update(elapsedTime);
		if (click()){
			((BubblefishEngine) parent).setLevel(myLevel);
			if(myLevel<myMaxLevel){
				parent.nextGameID=1;
			}
			else parent.nextGameID=4;
			
			
			finish();
		}
	}

}
